from django.conf.urls import url
from rest_framework.routers import DefaultRouter

from meiduo_admin.good import channels_view
from meiduo_admin.good import sku_images_view
from meiduo_admin.good import sku_views
from meiduo_admin.good import specs_options_views
from meiduo_admin.good import spu_specs_views
from meiduo_admin.good import spu_views
from meiduo_admin.order import order_view
from meiduo_admin.sysmange import admin_view
from meiduo_admin.sysmange import permission_group_view
from meiduo_admin.sysmange import permission_view
from . import views
from rest_framework_jwt.views import obtain_jwt_token

urlpatterns = [
    url(r'^authorizations/$',obtain_jwt_token),
    url(r'^statistical/total_count/$',views.UserTotalCountView.as_view()),
    url(r'^statistical/day_increment/$',views.UserDayIncrementCountView.as_view()),
    url(r'^statistical/day_active/$',views.UserDayActiveCountView.as_view()),
    url(r'^statistical/day_orders/$',views.UserDayOrdersCountView.as_view()),
    url(r'^statistical/month_increment/$', views.UserMonthIncrementCountView.as_view()),
    url(r'^statistical/goods_day_views/$',views.UserGoodsDayCountView.as_view()),

    # 用户路由
    url(r'^users/$',views.UserView.as_view()),

    #sku路由
    url(r'^skus/categories/$', sku_views.SKUCategoryView.as_view()),
    url(r'^goods/simple/$',sku_views.SKUSPUSimpleView.as_view()),
    url(r'^goods/(?P<spu_id>\d+)/specs/$',sku_views.SPUSpecificationView.as_view()),

    # spu 路由
    url(r'^goods/brands/simple/$',spu_views.SPUBrandSimpleView.as_view()),
    url(r'^goods/channel/categories/$',spu_views.SPUCategoryView.as_view()),
    url(r'^goods/channel/categories/(?P<category_id>\d+)/$',spu_views.SPUSubsCategoryView.as_view()),
    url(r'^goods/images/$',spu_views.SPUImageUploadView.as_view()),

    # 6,spec option路由
    url(r'^goods/specs/simple/$',specs_options_views.SpecSimpleView.as_view()),

    url(r'^skus/simple/$',sku_images_view.SKUSimpleView.as_view()),

    # 订单管理
    url(r'^orders/$',order_view.OrderInfoView.as_view()),
    url(r'^orders/(?P<pk>\d+)/$', order_view.OrderInfoDetailView.as_view()),
    # url(r'^orders/(?P<pk>\d+)/status/$',order_view.OrderInfoReadOnlymodelViewSet.as_view({"put":"status"}))

    # 权限管理
    url(r'^permission/content_types/$',permission_view.PermissionContentTypeView.as_view()),
    url(r'^permission/simple/$',permission_group_view.PermissionSimpleView.as_view()),
    url(r'^permission/groups/simple/$',admin_view.PermissionGruopView.as_view())
]


# 品牌管理
router = DefaultRouter()
router.register(r'goods/brands',channels_view.ChannelsViewSet,base_name="brands")
urlpatterns += router.urls



# 品牌管理
router = DefaultRouter()
router.register(r'goods/channels',channels_view.ChannelsViewSet,base_name="channels")
urlpatterns += router.urls

# sku管理
router = DefaultRouter()
router.register(r'skus',sku_views.SKUViewSet,base_name="skus")
urlpatterns += router.urls

#4,spu管理
router = DefaultRouter()
router.register(r'goods',spu_views.SPUViewSet,base_name="goods")
urlpatterns += router.urls

#5,spu spec管理
router = DefaultRouter()
router.register(r'goods/specs',spu_specs_views.SPUSpecsViewSet,base_name="specs")
urlpatterns += router.urls


#6,spec option管理
router = DefaultRouter()
router.register(r'specs/options',specs_options_views.SpecsOptionViewSet,base_name="options")
urlpatterns += router.urls


#7,sku image管理
router = DefaultRouter()
router.register(r'skus/images',sku_images_view.SKUImageViewSet,base_name="images")
urlpatterns += router.urls


#8,order order detail管理
router = DefaultRouter()
router.register(r'orders',order_view.OrderInfoReadOnlymodelViewSet,base_name="orders")
urlpatterns += router.urls


#9,permission管理
router = DefaultRouter()
router.register(r'permission/perms',permission_view.PermissionViewSet,base_name="permission")
urlpatterns += router.urls



# 10 permission groups 管理
router = DefaultRouter()
router.register(r'permission/groups',permission_group_view.PermissionGroupViewSet,base_name="groups")
urlpatterns += router.urls


#11,admin 管理
router = DefaultRouter()
router.register(r'permission/admins',admin_view.AdminMangerViewSet,base_name="admins")
urlpatterns += router.urls